#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
int moth(int n,int m)
{
	int day = 0;
		switch (m)
		{
			case 4:
			case 6:
			case 9:
			case 11:
				day = 30;
				break;
			case 1:
			case 3:
			case 5:
			case 7:
			case 8:
			case 10:
			case 12:
				day = 31;
				break;
			case 2:
				if (n % 4 == 0 && n || n % 100 == 0)
					day = 29;
				else
					day = 28;
				break;
			default:
				break;
		}
	return day;
}

int main()
{
	int n = 0;
	int m = 0;
	scanf("%d %d", &n, &m);
	int mid = moth(n, m);
	printf("%d\n", mid);
	return 0;
}